﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1072055, 0),
Array("", 1072056, 0),
Array("", 1072059, 0),
Array("", 1072060, 0),
Array("", 1072061, 0),
Array("", 1072062, 0),
Array("", 1072063, 0),
Array("", 1072064, 0),
Array("", 1072065, 0),
Array("", 1072066, 0),
Array("", 1072067, 0),
Array("", 1072068, 0),
Array("", 1072069, 0),
Array("", 1072070, 0),
Array("", 1072071, 0),
Array("", 1072072, 0),
Array("", 1072073, 0),
Array("", 1072074, 0),
Array("", 1072075, 0),
Array("", 1072076, 0),
Array("", 1072077, 0),
Array("", 1072078, 0),
Array("", 1072079, 0),
Array("", 1072080, 0),
Array("", 1072081, 0),
Array("", 1072082, 0),
Array("", 1072083, 0),
Array("", 1072084, 0),
Array("", 1072085, 0),
Array("", 1072006, 0),
Array("", 1072007, 0),
Array("", 1072008, 0),
Array("", 1072009, 0),
Array("", 1072011, 0),
Array("", 1072012, 0),
Array("", 1072015, 0),
Array("", 1072016, 0),
Array("", 1072017, 0),
Array("", 1072018, 0),
Array("", 1072019, 0),
Array("", 1072020, 0),
Array("", 1072021, 0),
Array("", 1072022, 0),
Array("", 1072023, 0),
Array("", 1072024, 0),
Array("", 1072025, 0),
Array("", 1072026, 0),
Array("", 1072027, 0),
Array("", 1072028, 0),
Array("", 1070023, 0),
Array("", 1071029, 0),
Array("", 1071035, 0),
Array("", 1071039, 0),
Array("", 1071041, 0),
Array("", 1072000, 0),
Array("", 1072001, 0),
Array("", 1072002, 0),
Array("", 1072003, 0),
Array("", 1072004, 0),
Array("", 1072005, 0),
Array("", 1072163, 0),
Array("", 1072164, 0),
Array("", 1072165, 0),
Array("", 1072166, 0),
Array("", 1072167, 0),
Array("", 1072168, 0),
Array("", 1072169, 0),
Array("", 1072170, 0),
Array("", 1072171, 0),
Array("", 1072172, 0),
Array("", 1072173, 0),
Array("", 1072174, 0),
Array("", 1072177, 0),
Array("", 1072178, 0),
Array("", 1072179, 0),
Array("", 1072182, 0),
Array("", 1072183, 0),
Array("", 1072184, 0),
Array("", 1072185, 0),
Array("", 1072192, 0),
Array("", 1072193, 0),
Array("", 1072194, 0),
Array("", 1072195, 0),
Array("", 1072196, 0),
Array("", 1072197, 0),
Array("", 1072198, 0),
Array("", 1072203, 0),
Array("", 1072204, 0),
Array("", 1072205, 0),
Array("", 1072206, 0),
Array("", 1072207, 0),
Array("", 1072208, 0),
Array("", 1072209, 0),
Array("", 1072210, 0),
Array("", 1072211, 0),
Array("", 1072212, 0),
Array("", 1072213, 0),
Array("", 1072214, 0),
Array("", 1072215, 0),
Array("", 1072216, 0),
Array("", 1072220, 0),
Array("", 1072221, 0),
Array("", 1072222, 0),
Array("", 1072223, 0),
Array("", 1072224, 0),
Array("", 1072225, 0),
Array("", 1072226, 0),
Array("", 1072227, 0),
Array("", 1072228, 0),
Array("", 1072229, 0),
Array("", 1072238, 0),
Array("", 1072239, 0),
Array("", 1072262, 0),
Array("", 1072263, 0),
Array("", 1072264, 0),
Array("", 1072268, 0),
Array("", 1072269, 0),
Array("", 1072272, 0),
Array("", 1072273, 0),
Array("", 1072275, 0),
Array("", 1072285, 0),
Array("", 1072288, 0),
Array("", 1072291, 0),
Array("", 1072294, 0),
Array("", 1072297, 0),
Array("", 1072300, 0),
Array("", 1072303, 0),
Array("", 1072306, 0),
Array("", 1072309, 0),
Array("", 1072312, 0),
Array("", 1072315, 0),
Array("", 1072318, 0),
Array("", 1072321, 0),
Array("", 1072338, 0),
Array("", 1072348, 0),
Array("", 1072355, 0),
Array("", 1072356, 0),
Array("", 1072357, 0),
Array("", 1072358, 0),
Array("", 1072359, 0),
Array("", 1072360, 0),
Array("", 1072361, 0),
Array("", 1072362, 0),
Array("", 1072363, 0),
Array("", 1072364, 0),
Array("", 1072365, 0),
Array("", 1072366, 0),
Array("", 1072368, 0),
Array("", 1072369, 0),
Array("", 1072375, 0),
Array("", 1072376, 0),
Array("", 1072383, 0),
Array("", 1072399, 0),
Array("", 1072400, 0),
Array("", 1072401, 0),
Array("", 1072402, 0),
Array("", 1072403, 0),
Array("", 1072418, 0),
Array("", 1072419, 0),
Array("", 1072420, 0),
Array("", 1072421, 0),
Array("", 1072422, 0),
Array("", 1072423, 0),
Array("", 1072434, 0),
Array("", 1072445, 0),
Array("", 1072447, 0),
Array("", 1072455, 0),
Array("", 1072463, 0),
Array("", 1072471, 0),
Array("", 1072472, 0),
Array("", 1072473, 0),
Array("", 1072474, 0),
Array("", 1072475, 0),
Array("", 1072476, 0),
Array("", 1072477, 0),
Array("", 1072485, 0),
Array("", 1072486, 0),
Array("", 1072487, 0),
Array("", 1072488, 0),
Array("", 1072489, 0),
Array("", 1072490, 0),
Array("", 1072491, 0),
Array("", 1072492, 0),
Array("", 1072493, 0),
Array("", 1072494, 0),
Array("", 1072502, 0),
Array("", 1072503, 0),
Array("", 1072504, 0),
Array("", 1072505, 0),
Array("", 1072506, 0),
Array("", 1072510, 0),
Array("", 1072518, 0),
Array("", 1072519, 0),
Array("", 1072521, 0),
Array("", 1072522, 0),
Array("", 1072533, 0),
Array("", 1072534, 0),
Array("", 1072538, 0),
Array("", 1072539, 0),
Array("", 1072540, 0),
Array("", 1072541, 0),
Array("", 1072542, 0),
Array("", 1072543, 0),
Array("", 1072544, 0),
Array("", 1072545, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到双头杖,灵魂手铳店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}